import http from '@/utils/http'
import fourWheelHttp from '@/utils/fourWheelHttp'
import _ from 'lodash'

export function getProvince() {
  const url = '/open/queryProvincesList'
  return http.post(url)
}
export function getCity(params) {
  const url = '/open/queryCitysList'
  return http.post(url, params)
}
export function getDistrict(params) {
  const url = '/open/queryDistrictList'
  return http.post(url, params)
}

export function getTaskId() {
  const url = '/xyyc/systemUser/getTaskId'
  return http.post(url)
}
// 商户验证码校验
export function openMerchantCode(params) {
  const url = '/open/merchantCode'
  return http.post(url, params)
}

// 商户申请
export function merchantApply(params) {
  const checkKey = localStorage.getItem('checkKey')
  const url = '/open/merchantApply'
  return http.request({
    method: 'post',
    url: url,
    data: params,
    headers: { 'rsa-check-key': checkKey },
  })
}

// 忘记密码
export function forgetPassword(params) {
  const checkKey = localStorage.getItem('checkKey')
  const url = '/open/forgetPassword'
  return http.request({
    method: 'post',
    url: url,
    data: params,
    headers: { 'rsa-check-key': checkKey },
  })
}

// 查询下级代理商
export function selectSubMerchant(params) {
  const url = '/login-open/selectSubMerchant'
  return http.post(url, params)
}
//获取广东六级地址
export function getGdAddress(params) {
  const url = '/login-open/outer-district/list'
  return http.post(url, params)
}

export function getWebLoginImg(params) {
  let paramsStr = ''
  let url = `/open/getSystemUserLoginCerificationImg?uuid=`
  _.each(params, (item, key) => {
    paramsStr = paramsStr + '&' + key + '=' + item
  })
  let realUrl = `${url}${new Date().getTime() + paramsStr}`
  return http.request({
    method: 'get',
    url: realUrl,
    responseType: 'blob',
  })
}
// 四轮验证码
export function getFourWheelWebLoginImg(params) {
  let paramsStr = ''
  let url = `/open/getSystemUserLoginCerificationImg?uuid=`
  _.each(params, (item, key) => {
    paramsStr = paramsStr + '&' + key + '=' + item
  })
  let realUrl = `${url}${new Date().getTime() + paramsStr}`
  return fourWheelHttp.request({
    method: 'get',
    url: realUrl,
    responseType: 'blob',
  })
}
